﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Draco.OWF.RT;
using Draco.OWF.DataBinding;
using Draco.OWF.Exceptions;
using Draco.OWF.RT.Engine;

namespace Draco.OWF.RT
{
    public class Job : AbstractJob
    {
        public Job(IProcess processTemplate, IBindingDataItemCollection startParameters)
            : base(processTemplate, startParameters) { }

       

        protected void Start()
        {
            //Find entry point of workflow
            IActivity startAc = this.m_processTemplate.StartActivity;
            if (startAc == null)
            {
                String msg = "can't find start activity of workflowProcess[Id=" + this.m_processTemplate.Id +
                    ";Name=" + this.m_processTemplate.Name + "]";
                throw new WorkflowException(msg);
            }
            ITask instance = startAc.CreateActivityInstance();
            this.m_ActivityInstances.Add(instance);
        }
        protected void MoveToNext(ITask IAc)
        {
            String activityId = IAc.Activity.Id;
            List<IActivity> list = this.m_processTemplate.GetNextActivities(activityId);
            foreach (IActivity ac in list)
            {
                ITask instance = ac.CreateActivityInstance();
                this.m_ActivityInstances.Add(instance);
            }
        }

        private void ChangeStatus()
        {
 
        }

        
        
    }
}
